﻿package mortal.game.view.market.buyAndQiugou
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class MktQiugouList extends GSprite
    {
        private var _titleRightBg:ScaleBitmap;
        private var _txtItemName:GTextFiled;
        private var _txtLevel:GTextFiled;
        private var _txtUintPrice:GTextFiled;
        private var _txtAction:GTextFiled;
        private var _itemList:GTileList;
        private var _btnSortUp:GLoadedButton;
        private var _btnSortDown:GLoadedButton;

        public function MktQiugouList()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatAnjin;
            this._titleRightBg = UIFactory.bg(1, 1, 470, 25, this, "RegionTitleBg");
            this._txtItemName = UIFactory.textField("物品名称", 61, 3, 60, 20, this, _loc_1);
            this._txtLevel = UIFactory.textField("等级", 192, 3, 30, 20, this, _loc_1);
            this._txtUintPrice = UIFactory.textField("单价", 283, 3, 30, 20, this, _loc_1);
            this._txtAction = UIFactory.textField("操作", 421, 3, 30, 20, this, _loc_1);
            this._btnSortUp = UIFactory.gLoadedButton(ImagesConst.ascendingSortBtn_upSkin, 317, 8, 11, 14, this);
            this._btnSortDown = UIFactory.gLoadedButton(ImagesConst.descendingSortBtn_upSkin, 330, 8, 11, 14, this);
            this._itemList = UIFactory.tileList(0, 25, 463, 354, this);
            this._itemList.rowHeight = 50;
            this._itemList.columnWidth = 460;
            this._itemList.rowCount = 7;
            this._itemList.horizontalGap = 0;
            this._itemList.verticalGap = 0;
            this._itemList.setStyle("cellRenderer", MktQiugouListItem);
            this._btnSortUp.configEventListener(MouseEvent.CLICK, this.onMouseClick);
            this._btnSortDown.configEventListener(MouseEvent.CLICK, this.onMouseClick);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._titleRightBg.dispose(param1);
            this._txtItemName.dispose(param1);
            this._txtLevel.dispose(param1);
            this._txtUintPrice.dispose(param1);
            this._txtAction.dispose(param1);
            this._itemList.dispose(param1);
            this._titleRightBg = null;
            this._txtItemName = null;
            this._txtLevel = null;
            this._txtUintPrice = null;
            this._txtAction = null;
            this._itemList = null;
            return;
        }// end function

        public function update() : void
        {
            var _loc_1:* = Cache.instance.market.marketItemObj.marketItems;
            this._itemList.dataProvider = new DataProvider(_loc_1);
            this._itemList.drawNow();
            return;
        }// end function

        private function onMouseClick(event:MouseEvent) : void
        {
            if (event.currentTarget == this._btnSortUp)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MarketClickSortUp));
            }
            if (event.currentTarget == this._btnSortDown)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MarketClickSortDown));
            }
            return;
        }// end function

    }
}
